package sat.component;

import org.mt4j.MTApplication;
import org.mt4j.components.visibleComponents.shapes.MTRectangle;
import org.mt4j.input.gestureAction.TapAndHoldVisualizer;
import org.mt4j.input.inputProcessors.IGestureEventListener;
import org.mt4j.input.inputProcessors.MTGestureEvent;
import org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor.TapAndHoldEvent;
import org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor.TapAndHoldProcessor;
import org.mt4j.util.MTColor;

public class UMLClass extends MTRectangle{
	private static final float width = 100;
	private static final float height = 150;

	protected boolean tappable = true;
	
	private UMLClass instance = this;

	public UMLClass(final MTApplication mtApplication) {
		super(mtApplication, width, height);

		this.setFillColor(MTColor.WHITE);
		this.setStrokeColor(MTColor.BLACK);
		this.setStrokeWeight(1);
		
		//gesture for deleting
		this.addGestureListener(TapAndHoldProcessor.class, new TapAndHoldVisualizer(mtApplication, this));
		this.registerInputProcessor(new TapAndHoldProcessor(mtApplication,1500));
		this.addGestureListener(TapAndHoldProcessor.class, new IGestureEventListener() {
			@Override
			public boolean processGestureEvent(MTGestureEvent ge) {
				TapAndHoldEvent e = (TapAndHoldEvent)ge;
				if (e.getId() == TapAndHoldEvent.GESTURE_ENDED && e.isHoldComplete()){
					System.out.println("start");
					e.stopPropagation();
					tappable = false;
					instance.destroy();
				}
				return false;
			}
		});

		//				this.unregisterAllInputProcessors();



		/*//gesture for XXXXX
				UnistrokeProcessor up = new UnistrokeProcessor(mtApplication);
				up.addTemplate(UnistrokeGesture.CIRCLE, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.CIRCLE, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.RECTANGLE, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.RECTANGLE, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.CHECK, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.TRIANGLE, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.TRIANGLE, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.PIGTAIL, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.PIGTAIL, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.ARROW, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.ARROW, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.STAR, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.STAR, Direction.COUNTERCLOCKWISE);
				up.addTemplate(UnistrokeGesture.V, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.QUESTION, Direction.CLOCKWISE);
				up.addTemplate(UnistrokeGesture.X, Direction.COUNTERCLOCKWISE);

				this.registerInputProcessor(up);
				this.addGestureListener(UnistrokeProcessor.class, new IGestureEventListener() {
					public boolean processGestureEvent(MTGestureEvent ge) {
						UnistrokeEvent ue = (UnistrokeEvent)ge;
						switch (ue.getId()) {
						case UnistrokeEvent.GESTURE_STARTED:
							MTPolygon p= ue.getVisualization();
							instance.addChild(p);
							break;
						case UnistrokeEvent.GESTURE_UPDATED:
							break;
						case UnistrokeEvent.GESTURE_ENDED:
							UnistrokeGesture g = ue.getGesture();
							System.out.println("Recognized gesture: " + g);
							break;
						default:
							break;
						}
						return false;
					}
				});
		 */

	}



}
